package com.ruihu.admin.module.business.log.interfacelog.domain.vo;

import com.ruihu.admin.module.business.log.interfacelog.domain.dto.InterfaceLogDTO;
import lombok.Data;
import java.util.Date;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;

/**
 *  [ 接口日志 ]
 *
 * @author Tony
 * @version 1.0
 * @company 瑞虎（南京）信息技术有限公司
 * @copyright (c) 瑞虎（南京）信息技术有限公司Inc. All rights reserved.
 * @date  2022-09-16 00:33:38
 * @since JDK1.8
 */

@Data
public class InterfaceLogVO {
    @ApiModelProperty("主键")
    private Long id;

    @ApiModelProperty("模块")
    private String module;

    @ApiModelProperty("内容")
    private String content;

    @ApiModelProperty("参数")
    private Map<String, Object> param;

    @ApiModelProperty("请求结果;请求结果 0失败 1成功")
    private Integer result;

    @ApiModelProperty("失败原因")
    private String failReason;

    @ApiModelProperty("乐观锁")
    private Integer revision;

    @ApiModelProperty("创建人")
    private Long createBy;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty("更新人")
    private Long updateBy;

    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;


    public static InterfaceLogVO convertToInterfaceLogVO(InterfaceLogDTO dto) {
        if (dto == null) {
            return null;
        }
        InterfaceLogVO vo = new InterfaceLogVO();
        vo.setId(dto.getId());
        vo.setModule(dto.getModule());
        vo.setContent(dto.getContent());
        vo.setParam(dto.getParam());
        vo.setResult(dto.getResult());
        vo.setFailReason(dto.getFailReason());
        vo.setCreateTime(dto.getCreateTime());
        vo.setUpdateTime(dto.getUpdateTime());
        return vo;
     }
}
